<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="/123/application/Public/Admin/Images/css1/css1.css" rel="stylesheet" type="text/css">
<script language='javascript' src='/123/application/Public/Admin/Js/jquery.js'></script>
<script type="text/javascript" src="/123/application/Common/Common/jquery-1.8.3.js"></script>
</head>

<SCRIPT language=javascript>
<!--
var displayBar=true;
function switchBar(obj){
	if (displayBar)
	{
		parent.frame.cols="0,*";
		displayBar=false;
		obj.value="打开左边管理菜单";
	}
	else{
		parent.frame.cols="195,*";
		displayBar=true;
		obj.value="关闭左边管理菜单";
	}
}

function fullmenu(url){
	if (url==null) {url = "admin_left.asp";}
	parent.leftFrame.location = url;
}

//-->
</SCRIPT>
<script type="text/javascript">
 $(function(){
	  GooodName();
	  $('#select').click(function(){
		  select();
		  var cid= $("#hidden").val();	  
		  var data={
				  id : cid
		  }
		 $.post('__MODULE__/Goods/createfirst',data,function(ms){
			 $(ms).each(function(i,item){
				 $("#goods_cate").html('');
				 //注意不能是item.cate.name   看看控制器不是关联模型了
				 $("<input/>").attr('type','text').val(item.name).appendTo($("#goods_cate"));
				 
			 });
		 });
	  });
	  
	function select(){
		//取出商品的id
		var goods_id=$("#goods_id").val();
		//var goods_cid=$("#goods_id").val();
		var data={
		 	id : goods_id,	 	
		}
		$.post('__MODULE__/Goods/selectok',data,function(msg){
		   $(msg).each(function(i,item){
			   $("#remark").html('');    //这样可以清空之前查询的值,如果是val()的就会一直清空其中的值;
			   $("#price").html(''); 
			   $("#photo").html('');
			   $("#cid").html('');
			   $("#hidden").html('');
			   
			   $("#hidden").val(item.cate.cid);
			   //$('<input/>').attr('type','text').val(item.cate.cid).appendTo($("#hidden"));
			   $("#cid").append(item.cate.name);
			   $('<input/>').attr('type','text').val(item.price).appendTo($("#price"));
		       $("#remark").append(item.remark);  
		       //$("input[name='photo']").attr('value',item.small_photo).appendTo($("#photo"));
		       $('<img/>').attr('src','/123/application/Public/Uploads/'+item.small_photo).appendTo($("#photo"));
		   });
		},'json');
	}
	
	
	
	function GooodName(){
		$.post('__MODULE__/Goods/createselect',function(msg){
			$(msg).each(function(i,item){
				$("#goods_id").append("<option value='"+item.id+"'>"+item.name+"</option>");
			});
		},'json');
	}
  });
</script>

<body>
<form method="POST" action="__URL__/selectok" enctype="multipart/form-data">
<table class="table" cellspacing="1" cellpadding="2" width="99%" align="center" 
border="0">

  <tbody>
    <tr>
      <th class="bg_tr" align="left" colspan="2" height="25">查询商品信息</th>
    </tr>
     <tr>
      <td class="td_bg" width="17%" height="23" align="right">商品名称</td>
      <td width="83%" class="td_bg">
      <select name='cid' id="goods_id">
      	<option value='0'>商品名</option>
      	<!--可以使用volist或则foreach解析数组-->
         <!--volist name='list' id='vo'  option value="{$vo.id}"  {$vo.name}  option  volist-->
      </select>
      </td>
    </tr>
      <tr>
      <td class="td_bg" width="17%" height="23"></td>
      <td class="td_bg" width="83%">
		<!--<input type='button' id='btnOk' value='录入' />-->
      	<input type="button" id="select" name="submit" value="点击查询" />
      	<!-- 此处需要注意使用ajax的时候一定要把type='submit'改为button -->
      </td>
    </tr>
      <tr>
      <td class="td_bg" width="17%" height="23" align="right">商品品牌</td>
      <td width="83%" class="td_bg" >
      <textarea name="cid" id='cid' rows='1' cols='20'></textarea>
      </td>
    </tr>
    <tr>
      <td class="td_bg" width="17%" height="23" align="right">商品类别</td>
      <td width="83%" class="td_bg" id="goods_cate">      
      	<!--  input type="text" name="cid" id='cid' value="{$list.cate.cid}" -->
      </td>
    </tr>
     <input type="hidden" name="goods_cate" id="hidden"/>
      <tr>
      <td class="td_bg" width="17%" height="23" align="right">商品价格</td>
      <td width="83%" class="td_bg" id="price">
      	<!--  input type="text" name="price" id='price' -->
      </td>
    </tr>
      <tr>
      <td class="td_bg" width="17%" height="50" align="right">商品图片</td>
      <td width="83%" class="td_bg" id="photo">
      	
      </td>
    </tr>
    <tr>
      <td class="td_bg" width="17%" height="23" align="right">商品描述</td>
      <td width="83%" class="td_bg">
      	<textarea name='remark' id='remark' rows='4' cols='80'></textarea>
      </td>
    </tr>
    
  </tbody>
</table>
</form>
</body>
</html>
